﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="VIPBuyPass.aspx.cs" Inherits="IHISCETeim.Web.AgentSys.VipMgr.VIPBuyPass" %>
<div class="pageContent">
	<form method="post" action="VipMgr/VIPBuyPass.aspx?ajaxmethod=edit&buyid=<%=BuyId %>" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
		<div class="pageFormContent" layoutH="56">            
            <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6;clear:both;">1.客户基本信息</h2>
                <p>
				    <label>姓名：</label>
				    <input name="RealName" type="text" class="required"  value="<%=vipObj.RealName %>" />
			    </p>                
                <p>
				    <label>联系方式：</label>
				    <input name="Tel" type="text" class=""  value="<%=vipObj.Tel %>" />
			    </p>
                <p>
				    <label>地址：</label>
				    <input name="Address" type="text" class=""  value="<%=vipObj.Address %>" />
			    </p>
           
                <p>
				    <label>VIP卡类型：</label>
                     <input name="VIPCardType" type="text" class="" readonly value="<%=vipObj.VIPCardType %>" />                   
			    </p>
                <p>
				    <label>VIP卡号：</label>
				    <input name="VIPCardNum" type="text" class="required" readonly value="<%=vipObj.VIPCardNum %>" />
			    </p>
            
             <div class="divider"></div>
             <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6;clear:both;">2.订单信息</h2>
                   <p>
				        <label>订单号：</label>
				        <input name="DocNum" type="text" class="required" readonly  value="<%=vipObj.DocNum %>" />
			      </p>
                  <p>
				        <label>采购日期：</label>
				        <input name="BuyDate" type="text" class="date required"  value="<%=vipObj.BuyDate.ToString("yyyy-MM-dd") %>" />
			      </p>
            
              <h2 style="clear:both; padding:5px; border-bottom:1px solid #B8D0D6; margin-bottom:5px; margin-top:15px; line-height:26px;">
                3.订单明细
                &nbsp;&nbsp;
                
            </h2>
                  <div  style=" clear:both;">
                        <table id="VIPBuyPass_AddDetail" class="list" width="100%" layouth="90" >
                        <thead>
                            <tr>                
                                <th width="100" >物料号</th>
                                <th>名称</th>                
                                <th width="100">单价</th> 
                                <th width="120">数量</th> 
                                <th>折扣</th> 
                                <th>小计</th>
                                <th>客户积分</th> 
                                <th>是否是工厂折扣件</th>             
                            </tr>
                         </thead>
                         <tbody>
                             <%--<tr >
				                <td><input type="text" name="ItemCode" readonly value="[物料号]" /></td>
				                <td><input type="text" name="ItemName" readonly value="[名称]" /></td>
				                <td><input type="text" name="Price" readonly value="[单价]" /></td>
                                <td><input type="text" name="Quantity" readonly value="[数量]" /></td>
                                <td><input type="text" name="DiscPrcnt" readonly value="[折扣]" /></td>
                                <td><input type="text" name="LineTotal" value="[小计]" /></td>
                                <td><input type="text" name="Point" value="[积分]" /></td>
			                    <td><input type="checkbox" name="IsDiscPiece" value="[积分]" /></td>
			                </tr>--%>
                            <asp:repeater id="rpDetail" runat="server">
                                <ItemTemplate>
                                    <tr >
				                        <td><input type="text" name="ItemCode"  readonly value='<%# Eval("ItemCode") %>' /></td>
				                        <td><input type="text" name="ItemName"  readonly value='<%# Eval("ItemName") %>' /></td>
				                        <td><input type="text" name="Price"  class="VIPBuyPass_Change" value='<%# Eval("Price") %>' /></td>
                                        <td><input type="text" name="Quantity"  class="VIPBuyPass_Change" value='<%# Eval("Quantity") %>' /></td>
                                        <td><input type="text" name="DiscPrcnt"  readonly value='<%# Eval("DiscPrcnt") %>' /></td>
                                        <td><input type="text" name="LineTotal"  readonly value='<%# Eval("LineTotal") %>' /></td>
                                        <td><input type="text" name="Point"  readonly value='<%# Eval("Point") %>' /></td>
			                            <td>
                                            <input type="hidden"  name="IsDiscPiece" value="<%# Convert.ToBoolean( Eval("IsDiscPiece")) %>" />
                                            <input type="checkbox" class="IsDiscPieceCheckbox" <%# Convert.ToBoolean( Eval("IsDiscPiece"))?"checked":"" %> />
			                            </td>
			                        </tr>
                                </ItemTemplate>
                            </asp:repeater>
                         </tbody>
                         <tfoot>
                             <tr>
                                <td colspan="5" style="text-align:right;">
                                总计:
                                </td>
                                <td  >
                                    <input type="hidden" id="VIPBuyPass_AddDetail_TotalMoney" name="TotalMoney" size="10" readonly value="<%=vipObj.TotalMoney %>" />     
                                    <input type="text" id="VIPBuyPass_AddDetail_DiscTotalMoney" name="DiscTotalMoney" size="10" readonly value="<%=vipObj.DiscTotalMoney %>" />                            
                                </td>
                                <td colspan="2">
                                    <input type="text" id="VIPBuyPass_AddDetail_TotalPoint" name="TotalPoint" size="10" readonly value="<%=vipObj.TotalPoint %>" />
                                </td>                        
                            </tr>
                         </tfoot>
                         </table>
                   </div>
        <script>
            $(document).ready(function(){
                $(".VIPBuyPass_Change").change(function(){
                    onVIPBuyPassAddChange($(this))
                })
                $(".IsDiscPieceCheckbox").change(function(){
                    $(this).closest("td").find("[name='IsDiscPiece']").val($(this).attr("checked"));
                })
            })
            //function openVIPBuyDetailLookUpList() {
            //    var rel = "VIPBuyDetailLookUpList";
            //    var url = "VipMgr/VIPBuyDetailLookUpList.aspx";
            //    var title = "选择配件(如果找不到相应配件,请通知IHISCE配件部)";
            //    var options = { width: 950, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            //    top.$.pdialog.open(url, rel, title, options);
            //}
            //function onVIPBuyDetailAddDelete($obj)
            //{
            //    $obj.closest("tr").remove();

            //    onTotalExec();
            //}
            function onVIPBuyPassAddChange($obj)
            {

                var $tr=$obj.closest("tr");
                var $Price=$tr.find(":text[name='Price']");
                var $Quantity=$tr.find(":text[name='Quantity']");
                var $DiscPrcnt=$tr.find(":text[name='DiscPrcnt']");

                var $LineTotal=$tr.find(":text[name='LineTotal']");
                var $Point=$tr.find(":text[name='Point']");               
          
               
                var _$LineTotal=parseFloat($Price.val())*parseFloat( $Quantity.val())*parseFloat($DiscPrcnt.val())
                $LineTotal.val(_$LineTotal.toFixed(2));

                var tempValid=1;
               <%-- <%
                //是否过期VIP卡
                if(!IHISCETeim.BLL.VIPCustomerHelper.GetValid(vipObj)){
                %>               
                tempValid=0;
                <%}%>--%>

                $Point.val(Math.round(tempValid*parseFloat( _$LineTotal)*<%=IHISCETeim.BLL.VIPCustomerHelper.GetMoenyToPoint(vipObj.VIPCardType)%>));

                onVIPBuyPassTotalExec();
            }

            function onVIPBuyPassTotalExec()
            {
                var $VIPBuyPass_AddDetail_DiscTotalMoney=$("#VIPBuyPass_AddDetail_DiscTotalMoney");
                var $VIPBuyPass_AddDetail_TotalMoney=$("#VIPBuyPass_AddDetail_TotalMoney");
                var $VIPBuyPass_AddDetail_TotalPoint=$("#VIPBuyPass_AddDetail_TotalPoint");
                var $VIPBuyPass_AddDetailTbody=$("#VIPBuyPass_AddDetail").find("tbody");

                var _TotalMoney=0;
                $VIPBuyPass_AddDetailTbody.find("input[name='LineTotal']").each(function () { 
                    var $Price=$(this).closest("tr").find(":text[name='Price']").val();
                    var $Quantity=$(this).closest("tr").find(":text[name='Quantity']").val();

                    _TotalMoney = _TotalMoney + parseFloat($Price)* parseFloat($Quantity);
                })
                $VIPBuyPass_AddDetail_TotalMoney.val(_TotalMoney.toFixed(2));

                var _DiscTotalMoney = 0;             
                $VIPBuyPass_AddDetailTbody.find("input[name='LineTotal']").each(function () {                
                    _DiscTotalMoney = _DiscTotalMoney + parseFloat($(this).val());
                })
                $VIPBuyPass_AddDetail_DiscTotalMoney.val(_DiscTotalMoney.toFixed(2));
                var _Point = 0;
                $VIPBuyPass_AddDetailTbody.find("input[name='Point']").each(function () {
                    // var $AllBalance = $("#FTradeBalanceAdd_AddBalanceList_AllBalance").val();
                    _Point = _Point + parseFloat($(this).val());
                })
                $VIPBuyPass_AddDetail_TotalPoint.val(_Point.toFixed(0));
            }
            ///单条记录返回
            <%--function onItemSelectClick(rowDate)
            {
               
                var $VIPBuyPass_AddDetailTbody=$("#VIPBuyPass_AddDetail").find("tbody");

                var $DiscPrcnt="<%=IHISCETeim.BLL.VIPCustomerHelper.GetDiscByVIPCardType(vipObj.VIPCardType)%>";              

                if( $VIPBuyPass_AddDetailTbody.find("#VIPBuyPass_AddDetail_Row"+ rowDate.ItemCode).attr("id")!=undefined)
                    return;
                var htmltemp = "<tr id='VIPBuyPass_AddDetail_Row" + rowDate.ItemCode + "' >" +
                               "     <td><input type=\"text\" name=\"ItemCode\" readonly value=\"[物料号]\" /></td>"+
				               "     <td><input type=\"text\" name=\"ItemName\" value=\"[名称]\" /></td>"+
				               "     <td><input type=\"text\" name=\"Price\" class='inputFloat' value=\"[单价]\" /></td>"+
				               "     <td><input type=\"text\" name=\"Quantity\" class='inputFloat'  value=\"[数量]\" /></td>"+
                               "     <td><input type=\"text\" name=\"DiscPrcnt\" readonly value=\"[折扣]\" /></td>"+
                               "    <td><input type=\"text\" name=\"LineTotal\"readonly value=\"[小计]\" /></td>"+
                               "    <td><input type=\"text\" name=\"Point\" readonly value=\"[积分]\" /></td>"+
                               "     <td><a href=\"javascript:\" title=\"删除\">删除</a></td>"+
                               "</tr>";

                var addHtml = htmltemp.replace("[物料号]", rowDate.ItemCode).replace("[名称]", rowDate.ItemName).replace("[单价]", rowDate.Price).replace("[数量]", rowDate.Quantity).replace("[折扣]", $DiscPrcnt).replace("[小计]", "0").replace("[积分]","0")
                ///alert(addHtml)
                $VIPBuyPass_AddDetailTbody.append($(addHtml).find("a").click(function () {
                    onVIPBuyDetailAddDelete($(this));
                }).end().find(":text[name='Price']").change(function () {
                    var $inputmoney = parseFloat($(this).val());
                    if ($inputmoney <= 0) {
                        alert("你所输入的单价小于0,请重输");
                        $(this).val("0");
                        return false;
                    }
                    onVIPBuyDetailAddChange($(this));
                }).end().find(":text[name='Quantity']").change(function () {
                    var $inputmoney = parseFloat($(this).val());
                    if ($inputmoney <= 0) {
                        alert("你所输入的数量小于0,请重输");
                        $(this).val("0");
                        return false;
                    }
                    onVIPBuyDetailAddChange($(this));
                }).end());
                $("#VIPBuyPass_AddDetail").find("tbody").find("input.inputFloat").inputFloat();
                onVIPBuyDetailAddChange($("#VIPBuyPass_AddDetail_Row" + rowDate.ItemCode ).find("a"));
                //alert(rowDate.ItemCode)


            }--%>
        </script>
        </div>
		<div class="formBar">
			<ul>
                <%if (HasPower(IHISCETeim.Web.Permission.VIPBuy_审核) && vipObj.OrderState=="审核中")
                  {%>
				<li id="" ><div class="buttonActive"><div class="buttonContent"><button type="submit" > 提交审核 </button></div></div></li>
                <%} %>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>